package com.yue.util;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;

/**
 * @author xiaochun
 */
public class CollectionTool {

    public static <T> boolean isNotEmpty(Collection<? extends T> collection){
        return collection != null && collection.size() > 0;
    }

    /**
     * @param collection 要判断的集合
     * @return 集合的元素是否唯一
     */
    public static <T> boolean isUnique(Collection<? extends T> collection) {
        if (!isNotEmpty(collection)){
            return false;
        }
        return collection.size() == new HashSet(collection).size();
    }


    public static void main(String[] args) {
        List<String> tests = new ArrayList<>();
        System.out.println(CollectionTool.isUnique(tests));
    }
}
